/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import entities.Restaurant;
import entities.Spot;
import java.util.List;
import java.util.Map;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ahmet
 */
@ManagedBean
@SessionScoped
public class RestBean2 {
    @PersistenceContext 
    private EntityManager em;

    private Restaurant restaurant;
    public Integer restId;
    
    public RestBean2() {
    }

    public Integer getRestId() {
        return restId;
    }

    public void setRestId(Integer restId) {
        this.restId = restId;
    }

    public Restaurant getRestaurant() {
        return restaurant;
    }

    public void setRestaurant(Restaurant restaurant) {
        this.restaurant = restaurant;
    }
    
    public List<Restaurant> findAllRest() {
        try {
            return (List<Restaurant>) em.createNamedQuery("Restaurant.findAll").getResultList();
        } catch (NoResultException nre) {
            return null;
        }
    }
}
